//package com.fyt.config.interceptor;
//
//import com.fyt.entity.User;
//import org.springframework.stereotype.Component;
//import org.springframework.web.servlet.HandlerInterceptor;
//import org.springframework.web.servlet.ModelAndView;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.text.SimpleDateFormat;
//import java.util.Date;
//import java.util.Map;
//import java.util.Set;
//
//
//@Component
//public class projectInterceptor implements HandlerInterceptor {
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//        String uri = request.getRequestURI();
//        System.out.println("请求相对路径: "+uri);
//        long l = System.currentTimeMillis();
//        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
//        String time = simpleDateFormat.format(new Date());
//        request.setAttribute("date",l);
//        System.out.println("请求时间: "+time);
//        String method = request.getMethod();
//        System.out.println("请求方法名: "+method);
//        int status = response.getStatus();
//        System.out.println("状态码: "+status);
//        System.out.println("参数信息:");
//        Map<String, String[]> parameterMap = request.getParameterMap();
//        Set<String> keySet = parameterMap.keySet();
//        for(String name : keySet){
//            String[] strings = parameterMap.get(name);
//            System.out.print(name + ": ");
//            for (String value : strings){
//                System.out.print(value + " ");
//            }
//            System.out.println();
//        }
//        if(uri.equals("/login") || uri.equals("/register")){
//            return true;
//        }
//        HttpSession session = request.getSession();
//        User users =(User) session.getAttribute("Users");
//        if(users!=null){
//            return false;
//        }
//        return true;
//    }
//    @Override
//    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
//    }
//    @Override
//    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
//        long date =(long) request.getAttribute("date");
//        long l = System.currentTimeMillis();
//        long s =l-date;
//        System.out.println("方法执行了 "+ s +"毫秒");
//    }
//
//}
